home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / exthandler / nsOSHelperAppService.h < prev   
C/C++ Source or Header  |  2006-05-08  |  9KB  |  167 lines

  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is the Mozilla browser.
  17.  *
  18.  * The Initial Developer of the Original Code is
  19.  * Netscape Communications, Inc.
  20.  * Portions created by the Initial Developer are Copyright (C) 1999
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   Scott MacGregor <mscott@netscape.com>
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  28.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. #ifndef nsOSHelperAppService_h__
  41. #define nsOSHelperAppService_h__
  42.  
  43. // The OS helper app service is a subclass of nsExternalHelperAppService and is implemented on each
  44. // platform. It contains platform specific code for finding helper applications for a given mime type
  45. // in addition to launching those applications.
  46.  
  47. #include "nsExternalHelperAppService.h"
  48. #include "nsCExternalHandlerService.h"
  49. #include "nsCOMPtr.h"
  50.  
  51. class nsHashtable;
  52. class nsILineInputStream;
  53.  
  54. class nsOSHelperAppService : public nsExternalHelperAppService
  55. {
  56. public:
  57.   nsOSHelperAppService();
  58.   virtual ~nsOSHelperAppService();
  59.  
  60.   // method overrides for mime.types and mime.info look up steps
  61.   already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType,
  62.                                                   const nsACString& aFileExt,
  63.                                                   PRBool     *aFound);
  64.  
  65.   // override nsIExternalProtocolService methods
  66.   NS_IMETHOD ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
  67.   nsresult LoadUriInternal(nsIURI * aURL);
  68.   NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
  69.  
  70.   // GetFileTokenForPath must be implemented by each platform. 
  71.   // platformAppPath --> a platform specific path to an application that we got out of the 
  72.   //                     rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform
  73.   // aFile --> an nsIFile representation of that platform application path.
  74.   virtual nsresult GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile);
  75.   
  76. protected:
  77.   already_AddRefed<nsMIMEInfoBase> GetFromType(const nsCString& aMimeType);
  78.   already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsCString& aFileExt);
  79.  
  80.   virtual void FixFilePermissions(nsILocalFile* aFile);
  81. private:
  82.   PRUint32 mPermissions;
  83.  
  84.   // Helper methods which have to access static members
  85.   static nsresult UnescapeCommand(const nsAString& aEscapedCommand,
  86.                                   const nsAString& aMajorType,
  87.                                   const nsAString& aMinorType,
  88.                                   nsHashtable& aTypeOptions,
  89.                                   nsACString& aUnEscapedCommand);
  90.   static nsresult GetFileLocation(const char* aPrefName,
  91.                                   const char* aEnvVarName,
  92.                                   PRUnichar** aFileLocation);
  93.   static nsresult LookUpTypeAndDescription(const nsAString& aFileExtension,
  94.                                            nsAString& aMajorType,
  95.                                            nsAString& aMinorType,
  96.                                            nsAString& aDescription,
  97.                                            PRBool aUserData);
  98.   static nsresult CreateInputStream(const nsAString& aFilename,
  99.                                     nsIFileInputStream ** aFileInputStream,
  100.                                     nsILineInputStream ** aLineInputStream,
  101.                                     nsACString& aBuffer,
  102.                                     PRBool * aNetscapeFormat,
  103.                                     PRBool * aMore);
  104.  
  105.   static nsresult GetTypeAndDescriptionFromMimetypesFile(const nsAString& aFilename,
  106.                                                          const nsAString& aFileExtension,
  107.                                                          nsAString& aMajorType,
  108.                                                          nsAString& aMinorType,
  109.                                                          nsAString& aDescription);
  110.  
  111.   static nsresult LookUpExtensionsAndDescription(const nsAString& aMajorType,
  112.                                                  const nsAString& aMinorType,
  113.                                                  nsAString& aFileExtensions,
  114.                                                  nsAString& aDescription);
  115.  
  116.   static nsresult GetExtensionsAndDescriptionFromMimetypesFile(const nsAString& aFilename,
  117.                                                                const nsAString& aMajorType,
  118.                                                                const nsAString& aMinorType,
  119.                                                                nsAString& aFileExtensions,
  120.                                                                nsAString& aDescription);
  121.  
  122.   static nsresult ParseNetscapeMIMETypesEntry(const nsAString& aEntry,
  123.                                               nsAString::const_iterator& aMajorTypeStart,
  124.                                               nsAString::const_iterator& aMajorTypeEnd,
  125.                                               nsAString::const_iterator& aMinorTypeStart,
  126.                                               nsAString::const_iterator& aMinorTypeEnd,
  127.                                               nsAString& aExtensions,
  128.                                               nsAString::const_iterator& aDescriptionStart,
  129.                                               nsAString::const_iterator& aDescriptionEnd);
  130.  
  131.   static nsresult ParseNormalMIMETypesEntry(const nsAString& aEntry,
  132.                                             nsAString::const_iterator& aMajorTypeStart,
  133.                                             nsAString::const_iterator& aMajorTypeEnd,
  134.                                             nsAString::const_iterator& aMinorTypeStart,
  135.                                             nsAString::const_iterator& aMinorTypeEnd,
  136.                                             nsAString& aExtensions,
  137.                                             nsAString::const_iterator& aDescriptionStart,
  138.                                             nsAString::const_iterator& aDescriptionEnd);
  139.  
  140.   static nsresult LookUpHandlerAndDescription(const nsAString& aMajorType,
  141.                                               const nsAString& aMinorType,
  142.                                               nsHashtable& aTypeOptions,
  143.                                               nsAString& aHandler,
  144.                                               nsAString& aDescription,
  145.                                               nsAString& aMozillaFlags);
  146.   
  147.   static nsresult DoLookUpHandlerAndDescription(const nsAString& aMajorType,
  148.                                                 const nsAString& aMinorType,
  149.                                                 nsHashtable& aTypeOptions,
  150.                                                 nsAString& aHandler,
  151.                                                 nsAString& aDescription,
  152.                                                 nsAString& aMozillaFlags,
  153.                                                 PRBool aUserData);
  154.   
  155.   static nsresult GetHandlerAndDescriptionFromMailcapFile(const nsAString& aFilename,
  156.                                                           const nsAString& aMajorType,
  157.                                                           const nsAString& aMinorType,
  158.                                                           nsHashtable& aTypeOptions,
  159.                                                           nsAString& aHandler,
  160.                                                           nsAString& aDescription,
  161.                                                           nsAString& aMozillaFlags);
  162.  
  163.   nsresult GetHandlerAppFromPrefs(const char* aScheme, nsIFile** aApp);
  164. };
  165.  
  166. #endif // nsOSHelperAppService_h__
  167.